
#include <bits/stdc++.h>

const int N = 1e6  + 10;

using namespace std;

int a[N];
int n,m;

int sp(int x,int y)
{
	while(x < y)
	{
		while(x < y and a[x] <= a[y])y--;
		if(x < y)swap(a[x],a[y]),x++;

		while(x < y and a[x] <= a[y])x++;
		if(x < y) swap(a[x],a[y]);
	}	
	return x;
}
int find(int x,int y,int target)
{
	int cur = sp(x,y);
	if(cur == target) return a[cur];
	else if(cur > target) return find(x,cur-1,target);
	else return find(cur+1,y,target);
}
void slove()
{
	cin >> n >> m;
	for(int i = 1;i <= n; i++)cin >> a[i];
	
	cout << find(1,n,m)<<endl;
	
}
int main() {
	int T = 1;
	//cin >> T;
	while(T--)slove();



	return 0;
}

